#ifndef MY_SDL_WINDOW_
#define MY_SDL_WINDOW_

#include <string>
#include <mutex>
#include <windows.h>
#include "YMessageList.h"

extern "C" {
#include "SDL.h"
}

//Refresh Event
#define SFM_REFRESH_EVENT  (SDL_USEREVENT + 1)
#define SFM_BREAK_EVENT  (SDL_USEREVENT + 2)

typedef enum {
	MY_SDL_NONE = 0x00000000,
	MY_SDL_SHOW = 0x00000004,              /**< window is visible */
	MY_SDL_HIDE = 0x00000008               /**< window is not visible */
}eMySDLFlags;

class MySDLWindow : public YMessageListInterface
{
public:
	MySDLWindow(int width, int height, eMySDLFlags flags);
	virtual ~MySDLWindow();
	bool Init();
	void DeInit();

	//implement YMessageListInterface
	void ProcessMessage();
	void SendMessage(uint8_t* data, const size_t len);
protected:
	static int  RefreshVideo(void *opaque);
	void RenderYuv(uint8_t* data, int len);
private:
	SDL_Window *  m_pWndMain;
	SDL_Renderer* m_pRenderer;
	SDL_Texture*  m_pTexture;
	SDL_Thread*   m_thead;
	int           m_thExit;
	int           m_thPause;

	int           m_width;
	int           m_height;
	uint32_t      m_flags;
	//SDL_Surface*  m_pSurface;
	std::string   m_strWndName;
	YMessageList* m_pMsg;
	std::mutex    m_mutex;
	bool          m_bExit;
};


#endif // MY_SDL_WINDOW_